import { defineStore } from "pinia";
import {ref} from 'vue'
export const userTokenStore = defineStore('token', () => {
  const token = ref('')

  const setToken = (newToken: string) => {
    token.value = newToken
    localStorage.setItem('token', newToken) // ✅ 直接存字符串
  }

  const removeToken = () => {
    token.value = ''
    localStorage.removeItem('token')
  }

  return { token, setToken, removeToken }
}, {
  persist: true
})